/**
 * Copyright (c) 2009 Cerner Corporation.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:
 *    Cerner Corporation - initial API and implementation
 */
package com.cerner.system.rest.internal.arguments;

import java.util.List;

/**
 * Internal API to verify that a URI conforms to the {@code <absolute-URI>}
 * syntax rule defined by RFC3986 section 4.3.
 * 
 * @author Alex Horn
 * @see <a
 *      href="http://tools.ietf.org/html/rfc3986#section-4.3">&lt;absolute-URI&gt;
 *      syntax rule</a>
 */
public class BaseUriValidator extends AbstractValidator {

  public boolean canValidate(Object argument) {
    return argument instanceof java.net.URI;
  }

  public boolean isValid(Object argument) {
    final java.net.URI uri = (java.net.URI) (argument);
    return uri.getPath() != null && uri.isAbsolute()
        && uri.getFragment() == null;
  }

  public String message(List<String> names) {
    return concat(names).concat(
        " must conform to the <absolute-URI> syntax rule defined by RFC3986 section 4.3");
  }

}
